package com.example.administrator.testhttpclient;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DefaultHttpClient;

import java.io.IOException;
import java.io.InputStream;

/**
 * Created by Administrator on 2015/11/24.
 */
public class CatchCheckCode {
    Bitmap bitmap;
    private static  HttpClient client = new DefaultHttpClient();

        public InputStream catchCheckCood(String url) throws Exception{

        HttpUriRequest request = new HttpGet(url);
        HttpResponse response = client.execute(request);
        HttpEntity entity = response.getEntity();
        Header[] ss = response.getAllHeaders();
        for (Header h:ss) {
            if(h.getName().equals("Set-Cookie")) {
                MainActivity.reinf.setCookie(h.getValue());
                Log.i("tiantong",h.getName());
            }
        }
        InputStream in = entity.getContent();

        if (in.available() >= 0) {
            return in;
        }else {
            return null;
        }


    }

}
